package com.example.spinning.service;

import com.example.spinning.bean.DailyReport;
import com.example.spinning.bean.SemiQuality;
import com.example.spinning.mapper.DailyReportMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Date;
import java.sql.Timestamp;
import java.util.List;


@Service
@Transactional
public class DailyReportService {
    @Autowired
    DailyReportMapper dailyReportMapper;


    //增加操作
    public int addNewDailyReport(DailyReport dailyReport) {
        return dailyReportMapper.addNewDailyReport(dailyReport);
    }

    //删除操作
    public boolean deleteDailyReportById(Long[] ids) {
        int result = dailyReportMapper.deleteDailyReportById(ids);
        return result == ids.length;
    }

    //查询并分页
    public PageInfo<DailyReport> findPage(Integer page, Integer size,String workshop,Date date,Long num) {

        DailyReport dailyReport = new DailyReport();
        dailyReport.setWorkshop(workshop);
        dailyReport.setNum(num);
        dailyReport.setDate(date);

        PageHelper.startPage(page,size);
        List<DailyReport> list = dailyReportMapper.select(dailyReport);
        PageInfo<DailyReport> pageInfo = new PageInfo<>(list);

        return pageInfo;
    }
    //动态修改
    public int updateCategoryById(DailyReport dailyReport){
        int result = dailyReportMapper.updateByPrimaryKeySelective(dailyReport);
        return result;
    }



}




